1575K - Knitting Batik - CodeForces Solution


implementation math *2200

Please click on ads to support us..

C++ Code:

#include <cstdio>
const long long MOD = 1000000007;
long long POWER(long long a, long long b, long long c)
{
	long long r = 1 % c;
	for (; b; b >>= 1)
	{
		if (b & 1)
			r = r * a % c;
		a = a * a % c;
	}
	return r;
}
int main()
{
	int n, m, k, r, c;
	scanf("%d%d%d%d%d", &n, &m, &k, &r, &c);
	int ax, ay, bx, by;
	scanf("%d%d%d%d", &ax, &ay, &bx, &by);
	if (ax == bx && ay == by)
		printf("%lld\n", POWER(k, (long long)n * m % (MOD - 1), MOD));
	else
		printf("%lld\n", POWER(k, ((long long)n * m - (long long)r * c) % (MOD - 1), MOD));
	return 0;
}


Comments

Submit
0 Comments
More Questions

84. Largest Rectangle in Histogram
60. Permutation Sequence
42. Trapping Rain Water
32. Longest Valid Parentheses
Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship